package com.example.vo.Fragment

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.example.vo.Data.History
import com.example.vo.R

class HistoryAdapter(val context: HistoryFragment, val history: List<History>) :
    RecyclerView.Adapter<HistoryAdapter.ViewHolder>() {
    inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
        val history_t:TextView = view.findViewById(R.id.history_t)
        val history_time:TextView = view.findViewById(R.id.history_time)
        val result_n:TextView = view.findViewById(R.id.result_n)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.history_item,parent,false)
        return ViewHolder(view)
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val history = history[position]
        holder.history_t.text = history.item
        holder.history_time.text = history.time
        holder.result_n.text = history.result
    }

    override fun getItemCount() = history.size
}